<?php if(!defined('IN_FANWE')) exit('Access Denied'); ?>
<?php 
$css_list[0]['url'] = './tpl/css/mailrss.css';
$js_list[0][] = './public/js/jquery.slides.js';
 include template('inc/header'); ?><div id="body" class="wrapper">

    <div id="content_body_wrap" class="fl mt20">

                <div class="piece" >
<div class="piece_hd" > <b class="hl"></b> <b class="hr"></b> </div>
                            <div class="piece_bd">
                                <h2 class="rss_cate_title" ><a href="<?php echo FU('mailrss/show',array("id"=>$cate_item['cate_id'])); ?>" >最新订阅</a></h2>
<ul class="rss_cate_list clear_in" >
                                    <?php if(is_array($rss_cates['list'])) { foreach($rss_cates['list'] as $cate_item) { ?> 
<li>
                                                <a class="fl cate_img" href="<?php echo FU('mailrss/show',array("id"=>$cate_item['cate_id'])); ?>" target="_blank"><img class="r5" height="80" src="<?php echo $cate_item['cate_icon'];?>" /></a>
                                                <h3 class="cr_t"><a class="glink" href="<?php echo FU('mailrss/show',array("id"=>$cate_item['cate_id'])); ?>" target="_blank"><?php echo $cate_item['cate_name'];?></a></h3>
                                                <p class="cr_i" ><span><b><?php echo $cate_item['rss_count'];?></b>成员订阅</span>  </p>
                                                <?php if($cate_item['is_rss'] == 1 ) { ?>
                                                    <p class="cr_d" >已订阅，<a  href="javascript:;" onclick="RemoveRss(<?php echo $cate_item['cate_id'];?>,this);">取消订阅</a></p>
                                                <?php } else { ?>
                                                    <p class="cr_d" ><a class="rss_a" href="javascript:;" onclick ="AddRss(<?php echo $cate_item['cate_id'];?>,this);">订阅</a></p>
                                                <?php } ?> 
                                        </li>
                                    <?php } } ?>
</ul>
</div>
                 
<div class="piece_ft" > <b class="fl"></b> <b class="fr"></b> </div>
</div>
        </div>

        <div id="right_side" class="fr mt20">
        <div class="piece piece_ws" >
<div class="piece_hd" > <b class="hl"></b> <b class="hr"></b> </div>
<div class="piece_bd">
<h3>订阅快报</h3>
                                <?php if($rss_user_list) { ?>
<ul class="rss_user_list">
                                    <?php if(is_array($rss_user_list['list'])) { foreach($rss_user_list['list'] as $rss_user_item) { ?><li>
<p><a class="tlink" target="_blank" href="<?php echo FU('u/index',array("uid"=>$rss_user_item['uid'])); ?>"><?php echo $rss_user_item['user_name'];?></a>订阅了</p>
<p class="gl_gt" ><a class="glink" target="_blank" href="<?php echo FU('mailrss/show',array("id"=>$rss_user_item['cate_id'])); ?>"><?php echo $rss_user_item['short_name'];?></a></p>
</li>
                                       <?php } } ?>
</ul>
                                <?php } ?>
</div>
<div class="piece_ft" > <b class="fl"></b> <b class="fr"></b> </div>
</div>
            </div>
</div><?php include template('inc/footer'); ?><script>
function AddRss(cate_id,obj){
        var query = new Object();
        query.cate_id = cate_id;
        if(USER_ID == 0){
            alert('请先登录，再进行订阅操作！');
        }
        $.ajax({    
                    url: SITE_PATH+"mailrss.php?action=ajax_rss",
                    type: "POST",
                    data:query,
                    cache:false,
                    dataType:'json',
                    success:function(result){
                            if(result.status == 0){
                                alert('订阅失败,请稍候再试！');
                            }
                            else
                            {   
                                var rss_count = parseInt($(obj).parent().parent().find("b").html());
                                $(obj).parent().parent().find("b").html(rss_count+1);
                                var html_str = '已订阅，<a href="javascript:;" onclick="RemoveRss('+query.cate_id+',this);">取消订阅</a>';
                                $(obj).parent().html(html_str);
                            }
                    },
                    error:function(){
                            
                    }
                });
 }
function RemoveRss(cate_id,obj){
        var query = new Object();
        query.cate_id = cate_id;
        $.ajax({    
                    url: SITE_PATH+"mailrss.php?action=ajax_remove_rss",
                    type: "POST",
                    data:query,
                    cache:false,
                    dataType:'json',
                    success:function(result){
                            if(result.status == 0){
                                alert('取消订阅失败,请稍候再试！');
                            }
                            else
                            {
                                var rss_count = parseInt($(obj).parent().parent().find("b").html());
                                $(obj).parent().parent().find("b").html(rss_count-1);
                                var html_str = '<a class="rss_a" href="javascript:;" onclick ="AddRss('+cate_id+',this);">订阅</a>';
                                $(obj).parent().html(html_str);
                            }
                    },
                    error:function(){
                            
                    }
                });
}
</script>